<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:t="http://myfaces.apache.org/tomahawk"
	xmlns:util="http://java.sun.com/jsf/composite/util">

<ui:composition>
	<h:form>
		<h:panelGrid styleClass="vertical-menu-cell"
			columnClasses="optionList" columns="1" cellspacing="0"
			cellpadding="0">
			<rich:dropDownMenu
				style="border:1px solid #{a4jSkin.panelBorderColor}" label="Akcje"
				mode="server" jointPoint="topRight" direction="bottomRight">
				<rich:menuItem label="Edytuj"
					action="#{manageClientBean.editClient}">
					<!--				<f:facet name="icon">-->
					<!--					<h:graphicImage value="/images/icons/print.gif" alt="print" />-->
					<!--				</f:facet>-->
				</rich:menuItem>
				<rich:menuItem label="Usuń"
					action="#{manageClientBean.removeClient}" />
			</rich:dropDownMenu>
			<h:commandButton value="Odśwież"
					actionListener="#{adminPanelBean.refreshUserList}"/>
		</h:panelGrid>
	</h:form>
	<h:form>

		<rich:extendedDataTable value="#{adminPanelBean.client_list}"
			var="client" id="user_table" sortMode="single" frozenColumns="1"
			selectionMode="single" selection="#{adminPanelBean.selection}">
			<a4j:ajax execute="@form" event="selectionchange"
				listener="#{adminPanelBean.selectionUserListener}" render="@all" />
			<f:facet name="header">
				<h:outputText value="Tabela zarejestrowanych klientów" />
			</f:facet>

			<rich:column>
				<f:facet name="header">
					<h:outputText value="Imie" />
				</f:facet>
				<h:outputText value="#{client.first_name}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Nazwisko" />
				</f:facet>
				<h:outputText value="#{client.last_name}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="e-mail" />
				</f:facet>
				<h:outputText value="#{client.email}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Ulica" />
				</f:facet>
				<h:outputText value="#{client.street}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Nr. domu" />
				</f:facet>
				<h:outputText value="#{client.house_number}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Nr. mieszkania" />
				</f:facet>
				<h:outputText value="#{client.apartment_number}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Kod pocztowy" />
				</f:facet>
				<h:outputText value="#{client.postal_code}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Poczta" />
				</f:facet>
				<h:outputText value="#{client.post}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Telefon" />
				</f:facet>
				<h:outputText value="#{client.phone}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Data urodzenia" />
				</f:facet>
				<h:outputText value="#{client.date_of_birth}" />
			</rich:column>
		</rich:extendedDataTable>
	</h:form>

	<h:form>
		<rich:panel>
			<h:panelGrid columns="1">
				<h:panelGrid columns="2" cellpadding="4">
					<util:formField
						beanProperty="#{manageClientBean.client.first_name}"
						title="Imię" size="48" required="true" />
					<util:formField
						beanProperty="#{manageClientBean.client.last_name}"
						title="Nazwisko" size="49" required="true" />
				</h:panelGrid>
				<h:outputText value="Data urodzenia: " styleClass="formOutputField" />
				<rich:calendar value="#{manageClientBean.client.date_of_birth}"
					id="calendar" datePattern="d/M/yy" showApplyButton="true"
					cellWidth="24px" cellHeight="22px" style="width:200px">
				</rich:calendar>
				<br />
				<h:outputText value="Adres:" style="font-size: 14px;" />
				<h:panelGrid columns="3" cellpadding="4">
					<util:formField beanProperty="#{manageClientBean.client.street}"
						title="Ulica" size="50" required="true" />
					<util:formField
						beanProperty="#{manageClientBean.client.house_number}"
						title="Nr domu" size="20" required="true" />
					<util:formField
						beanProperty="#{manageClientBean.client.apartment_number}"
						title="Nr mieszkania" size="20" required="true" />
				</h:panelGrid>
				<h:panelGrid columns="2" cellpadding="4">
					<util:formField beanProperty="#{manageClientBean.client.post}"
						title="Poczta" size="70" required="true" />
					<util:formField
						beanProperty="#{manageClientBean.client.postal_code}"
						title="Kod pocztowy" size="27" required="true" />
				</h:panelGrid>
				<br />

				<h:outputText value="Kontakt:" style="font-size: 14px;" />
				<util:formField beanProperty="#{manageClientBean.client.email}"
					title="E-mail" size="106" required="true" />
				<util:formField beanProperty="#{manageClientBean.client.phone}"
					title="Telefon" size="106" required="true" />
			</h:panelGrid>

			<t:div style="text-align:center;">
				<h:commandButton value="Zapisz"
					actionListener="#{manageClientBean.createClient}" />
				<h:commandButton value="Anuluj"
					action="#{jsfutils.redirect('mainContent/booksTablePage')}" />

			</t:div>
		</rich:panel>
	</h:form>

</ui:composition>
</html>
